<template>
	<view class="component">
		<view class="form">
			<view class="form-item">
				<input-custom :model="contactInfo.is_principal" name="是否是负责人" inputType="select" :options="principalList"
					@inputComplete="(value)=>inputComplete('is_principal',value,'select')"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.is_policymaker" name="是否是决策人" inputType="select" :options="principalList"
					@inputComplete="(value)=>inputComplete('is_policymaker',value,'select')"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.working_hours" name="工作年限" 
					@inputComplete="(value)=>inputComplete('working_hours',value)"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.marriage_state" name="婚否" inputType="select" dicCode="marriage_state"
					@inputComplete="(value)=>inputComplete('marriage_state',value,'select')"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.brithday" name="生日" inputType="time"
					@inputComplete="(value)=>inputComplete('brithday',value,'time')"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.child_total" name="子女" inputType="select" :options="childList"
					@inputComplete="(value)=>inputComplete('child_total',value,'select')"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.relation" name="客情关系"  
					@inputComplete="(value)=>inputComplete('relation',value)"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.interest" name="爱好" 
					@inputComplete="(value)=>inputComplete('interest',value)"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.value_concept" name="价值观" 
					@inputComplete="(value)=>inputComplete('value_concept',value)"></input-custom>
			</view>
			<view class="form-item">
				<input-custom :model="contactInfo.remark" name="备注" inputType="textarea"
					@inputComplete="(value)=>inputComplete('remark',value)"></input-custom>
			</view>
		</view>
		
	</view>
</template>

<script>
	import inputCustom from '@/pages-personal/common/inputCustom.vue'
	export default {
		components: {
			inputCustom
		},
		props:{
			contactInfo:{
				type:Object,
				default:{}
			},
			type:{
				type:String,
				required:true
			}
		},
		data() {
			return {
				principal: "",
				principalList: [{text:'是',value:1},{text:'否',value:2}],
				childList:[{text:'有',value:'有'},{text:'无',value:'无'}]
			}
		},
		methods: {
			inputComplete(key,value,type) {
				if(type == 'select'||type == 'picker-select'){
					this.$set(this.contactInfo,key,value['value']);
				}else{
					this.$set(this.contactInfo,key,value)
				}
				let data = {
					id: this.contactInfo.id,
					[key]:this.contactInfo[key]
				}
				let url = '';
				if(this.type == 1) {
					url = '/api/business/contact/handle';
				} else {
					url = '/api/member/business/contact/handle';
				}
				this.$http.post(url, data).then((res) => {
					if(res.data.status == 200) {
						
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.component {
		display: flex;
		flex-direction: column;
		height: 100%;
	}

	.form {
		flex: 1;
		height: 100%;
		padding: 30rpx 40rpx;

		.form-item {
			margin-bottom: 60rpx;
			
		}
	}

	
</style>